//
//  FirCirCommentInfo.m
//  tcpoctest
//
//  Created by gump on 4/16/13.
//  Copyright (c) 2013 gump. All rights reserved.
//

#import "FirCirCommentInfo.h"

@implementation FirCirCommentInfo

-(id)init
{
    self = [super init];
    if (self != nil) {
        self.mail = @"";
        self.newsID = @"";
        self.speaker = @"";
        self.speakto = @"";
        self.strtime = @"";
        self.stIndex = FCG_ONE_TEXT;
        self.commentID = @"";
        self.content = @"";
    }
    
    return  self;
}

-(NSString*)TurnTimeString
{
    NSArray *array = [self.strtime componentsSeparatedByString:@"/"];
    
    if ([array count] != 6) {
        return @"";
    }
    
    NSString *stryear = [array objectAtIndex:0];
    int year = [stryear intValue];
    
    NSString *time = @"";
    
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *comps = [[NSDateComponents alloc] init];
    NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit |
    NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
    NSDate *curdate = [NSDate date];
    comps = [calendar components:unitFlags fromDate:curdate];
    int curyear=[comps year];
    
    if (curyear != year) {
        time = [NSString stringWithFormat:@"%d年",year];
    }
    else
    {
        stryear = [array objectAtIndex:1];
        year = [stryear intValue];
        
        time = [NSString stringWithFormat:@"%@%d月",time,year];
        
        stryear = [array objectAtIndex:2];
        year = [stryear intValue];
        
        time = [NSString stringWithFormat:@"%@%d日",time,year];
        
        stryear = [array objectAtIndex:3];
        year = [stryear intValue];
        
        if (year < 10) {
            time = [NSString stringWithFormat:@"%@0%d:",time,year];
        }
        else
        {
            time = [NSString stringWithFormat:@"%@%d:",time,year];
        }
        
        stryear = [array objectAtIndex:4];
        year = [stryear intValue];
        
        if (year < 10) {
            time = [NSString stringWithFormat:@"%@0%d:",time,year];
        }
        else
        {
            time = [NSString stringWithFormat:@"%@%d:",time,year];
        }
        
        stryear = [array objectAtIndex:5];
        year = [stryear intValue];
        
        if (year < 10) {
            time = [NSString stringWithFormat:@"%@0%d",time,year];
        }
        else
        {
            time = [NSString stringWithFormat:@"%@%d",time,year];
        }
    }
    
    return time;
}

@end
